//
//  MessageViewController.m
//  ShouYi
//
//  Created by yrapp on 16/2/23.
//  Copyright © 2016年 yurui. All rights reserved.
//

#import "MessageViewController.h"
#import "messageHeaderView.h"

#import "MessageTableViewCell.h"
#import "DetailViewController.h"
@interface MessageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong)messageHeaderView *headerView;
@property (nonatomic,strong)UITableView *tableView;
@end

@implementation MessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self addMessageHeaderView];
    [self addTableView];
    // Do any additional setup after loading the view.
}


//headerVeiw
- (void)addMessageHeaderView {
    self.headerView = [[messageHeaderView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 64)];
    self.headerView.backgroundColor = kBackGroundColor;
    [self.headerView.backButton addTarget:self action:@selector(back) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:self.headerView];
}

//添加tableView
- (void)addTableView {
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, kWidth, kHeight - 64) style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor colorWithRed:235.0/255 green:235.0/255 blue:235.0/255 alpha:1];
    [self.tableView registerClass:[MessageTableViewCell class] forCellReuseIdentifier:@"cell"];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    
}


- (void)back {
    [self.navigationController popViewControllerAnimated:YES];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return 20;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 101;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    self.hidesBottomBarWhenPushed = YES;
    WebViewController *WebVC = [[WebViewController alloc] init];
    WebVC.webUrl = @"http://cs.000e.com/7/shouyi/details.html";
    [self.navigationController pushViewController:WebVC animated:YES];
    
    
    
    
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
